Skip to content

Add optional print correction for resin overcure - #6

Merged
Jujified merged 11 commits into
mainfrom
claude/nifty-tesla-xbf8ta
Nov 10, 2026
Merged

Jujified merged 11 commits into
mainfrom
claude/nifty-tesla-xbf8ta

Conversation

@Jujified

@Jujified Jujified commented Nov 9, 2026 •

Copy link
Copy Markdown
Owner

What this changes

Resin printers cure past the intended edge and through the layers above a channel, which narrows small channels and lowers their ceilings. This adds an optional correction for that at export time, driven by a calibration profile for one printer and resin, plus the tooling to make the profile and a preview of the corrected geometry.

It is off by default. With Print correction on None (uncompensated), the app behaves and exports as it does today.

Profile file (.ocdfm) – src/lib/dfm/profile.ts
A standalone, versioned JSON file: setup metadata, the fitted parameters, the coupon version and the raw coupon measurements, so a profile can be re-fitted later. Every field is validated with plain-language errors. A newer schemaVersion is refused with a readable message rather than half-applied. Identity is a SHA-256 of a canonical form, so reformatting a file does not change it.

Compensation – src/lib/dfm/model.ts, compensate.ts
compensateDesign(nominal, profile) is one pure function returning a second design and a conflict list. The STL export, the OpenSCAD export and the preview all call it.

  • Lateral bleed becomes wider dimension markers on a copy of the graph, and larger chambers and drainage vents. The model superposes the exponential stray-dose tails of a channel's two walls, so narrow channels lose more and close at 2Δ + 2λ·ln 2. With λ = 0 it is a constant offset.
  • Vertical cure-through becomes a ceiling raise with the floor fixed. It is the one thing the graph cannot express, so it travels as a single optional ceilingRaiseMm (default 0) through placeChannel, profilePoints, buildChip and exportScad. This is the only change to the existing pipeline.
  • Conflicts (thin wall, merge, edge clearance, thin roof, breakthrough) are reported only when compensation created or worsened them, with the features and the shortfall. They are a caution box and never block an export.

Coupon and fit – coupon.ts, fit.ts
The coupon is an ordinary monolithic project built from nodes, segments and drainage vents, with channels run through both side walls so they are open at both ends. Groups are labelled with tally dots, since there is no text primitive. Open/partial/closed results give a bracket and the UI calls the fit coarse; measured dimensions give a least-squares fit with a residual.

UI – src/components/dfm/, CadPanel.tsx
A profile selector in the Export section. With a profile selected: the offsets applied, the conflict list, a Preview DFM toggle beside the STL button, and a read-only preview panel (top view, draggable slice line with cross-sections, legend, fullscreen). A calibration dialog covers coupon, results and saving the profile. No hint or prompt is shown to users who never open it.

Project file
One optional field, dfmProfileRef (name and hash of the profile last exported with). It is never defaulted, so existing files load and save unchanged and formatVersion stays at 1. The selection itself is not persisted: every session starts uncompensated.

Compensated exports get a -dfm-<profile> file suffix and record the profile name and hash in the STL header and the OpenSCAD header comments. SVG, PNG and the presentation bundle are not corrected.

No new dependencies.

How it was checked

  • npm run build && npm test && npm run lint pass (527 tests)
  • Tried in the running app, in light and dark: loaded a profile, toggled the preview, zoomed, dragged the slice line, opened and closed fullscreen with Esc, exported STL and OpenSCAD with and without a profile, ran the calibration dialog end to end, opened the coupon in the editor. No console errors.

Tests added:

  • goldenExport.test.ts: every template and shipped project file exported as STL, OpenSCAD and SVG through the no-profile path and compared byte-for-byte (SHA-256) with a baseline recorded before any feature code. Each chip is built twice to assert the exporter is deterministic.
  • Profile parse, round-trip, error messages and version handling.
  • Model arithmetic and hand-checked compensation cases, including that the nominal design is never modified.
  • Conflict detection for each kind.
  • Coupon: valid project, builds through the normal pipeline, every channel open at both faces, measurement sheet reads back.
  • Fit: recovers known offsets from synthetic coupon results, and brackets them for open/closed data.
  • preview.test.ts: the preview's cross-sections equal a slice of the mesh built through the export path, for rectangular, trapezoidal and round channels.

For reviewers

  • Not verified on a printer. The model shape, the default coupon sizes and the fit are checked against synthetic data only. Nothing here has been confirmed against a physical print.
  • The ceiling raise applies to monolithic chips only. Two-piece and glass-slide channels are open grooves with no printed roof, so they get the lateral correction alone.
  • Ports and fittings are deliberately left nominal.
  • A round channel is corrected as a larger circle, which also lowers its floor by the lateral offset.
  • The vertical offset is one value per profile, not width-dependent.
  • The coupon opens with a long list of design-check warnings, because its channels run outside the chip on purpose. The dialog says so.
  • src/lib/wikiLinks.ts gains a printCorrection link; the documentation page for it is prepared separately.

Exports every starter template and shipped project file as STL, OpenSCAD
and schematic SVG, and compares SHA-256, size, triangle count, volume and
bounds with a recorded baseline. Each chip is built twice to assert the
exporter is deterministic, which is what makes comparing bytes sound.

Re-record with UPDATE_GOLDEN=1 npm test -- goldenExport.
@vercel

vercel Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
open-chip Ready Ready Preview Nov 10, 2026 8:59pm UTC

A standalone, versioned JSON file describing how one printer and resin
depart from the geometry they are asked to print: setup metadata, fitted
compensation parameters, the coupon version and the raw coupon
measurements, so a profile can be re-fitted later.

Parsing validates every field with plain-language errors, refuses a
newer schema version with a readable message, and hashes a canonical
form so reformatting a file does not change its identity.
compensateDesign is one pure function from a nominal design and a
profile to the design to print, plus a list of conflicts. Lateral bleed
becomes wider dimension markers on a copy of the graph (and larger
chambers and drainage vents); vertical cure-through becomes a ceiling
raise that the pipeline applies to every roof, leaving floors where they
were drawn.

The lateral model superposes the exponential stray-dose tails of a
channel's two walls, so narrow channels lose more and close at
2*delta + 2*lambda*ln 2. With lambda = 0 it is a constant offset.

The ceiling raise is one optional parameter, default 0, through
placeChannel, profilePoints, buildChip and exportScad. The default
export baseline is unchanged.

Conflicts are walls pushed under the printable minimum, channels that
merge, features pushed into the edge spacing, and roofs left too thin or
broken through, each with the features involved and the shortfall.
The coupon is an ordinary monolithic project: straight rectangular
channels, one per width x height, each running through both side walls
so it can be flushed and sighted through. Groups are labelled with tally
dots, blind holes made from drainage vents, since there is no text
primitive. A matching CSV measurement sheet is generated and reads back
in.
Measured dimensions give a least-squares fit with a residual; the decay
length is fitted only when three or more widths were measured and it
cuts the error by more than a tenth. Open/partial/closed results give
only the interval between the largest size that closed and the smallest
that stayed open, which the fit reports alongside a point estimate and a
note that the result is coarse.
Outlines and cross-sections of the nominal and the compensated design,
built from the result of compensateDesign with the same loft, placement
and profile functions the STL uses. The tests build the compensated chip
through the export path and compare the mesh with what the preview
draws, for rectangular, trapezoidal and round channels.
planExport returns the nominal design by identity when no profile is
selected, with the file name and STL header the app has always written.
With a profile it carries the compensated design, a -dfm-<profile> file
suffix, and the profile name and hash for the STL header and the
OpenSCAD source. The default-export baseline now runs through it.

A project may record the profile it was last exported with as an
optional dfmProfileRef (name and SHA-256). It is never defaulted, so
existing files load and save unchanged, and no format version bump is
needed. Loaded profiles live in a browser-level store; the selection is
not persisted, so every session starts uncompensated.
A profile selector in the Export section, defaulting to None
(uncompensated). With a profile selected: the offsets applied, a
non-blocking list of conflicts, a Preview DFM toggle beside the STL
button, and a read-only preview panel with a top view, a draggable slice
line with cross-sections, a legend and a fullscreen view.

A calibration dialog generates the coupon and its measurement sheet,
takes open/partial/closed results and optional measured dimensions, shows
the fit with what it rests on, and saves a .ocdfm profile.
Draw the open/partial/closed marks rather than relying on Unicode
glyphs, keep the STL and Preview DFM buttons on one row in the sidebar,
cap the preview zoom, and let a click place the slice line, which is
usually off-screen once zoomed in.

A roof that already broke through the top face as drawn is no longer
reported as a conflict caused by the ceiling raise.
README: the feature in the list, a short usage section and a link to the
guide. ARCHITECTURE: how the transform, the profile, the fit, the coupon
and the preview fit together, and what the model assumes. The skill's
schema reference gains the optional dfmProfileRef field.
@Jujified Jujified changed the title Add a byte-level regression baseline for default exports Add optional print correction for resin overcure Nov 10, 2026
@Jujified
Jujified marked this pull request as ready for review November 10, 2026 21:14
Copilot AI balanced review requested due to automatic review settings November 10, 2026 21:14

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@Jujified
Jujified merged commit 2f6084b into main Nov 10, 2026
3 checks passed

This branch was successfully deployed

1 active deployment
Preview — 76db7e6d Deployed Nov 10, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants